<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@taglib prefix="t" tagdir="/WEB-INF/tags"%>
<%@taglib prefix="error" uri="/WEB-INF/tags/ErrorTag.tld"%>

<t:basicTemplate pageTitle="SWIMv2 - ${userName} - Profile">
	<jsp:attribute name="extrahead">
		<link rel='stylesheet' href='css/user.css' type='text/css' />
	</jsp:attribute>
	<jsp:body>
        <h1>User Profile</h1>
        
        <div class="error-style">
			<error:errors error="${param.error}"></error:errors>
		</div>

        <c:if test="${image != ''}">
        	<img src="${image}" />
        </c:if>
        
        <c:if test="${image == ''}">
        	<img src="http://placekitten.com/150/150" />
        </c:if>
        
        <br />
        
   		<c:forEach var="entry" items="${userMap}">
			<c:if test="${entry.key != 'image' && entry.key != 'category'}">
				${entry.key}: ${entry.value}<br>
				<br>
			</c:if>
		</c:forEach>
		
		<p>
        	Feedback average: ${avg_feed}/10
        	<c:if
				test="${sessionScope.user_type == 'logged' || sessionScope.user_type == 'admin'}">
        		<a href="./seeFeedbacks?user=${userMap['username']}">See all my feedbacks</a>
        	</c:if>
       	</p>
       	
       	<form method="POST" action="./proceedFriendshipRequest">
			<input type="hidden" value="${userMap['username']}" name="newFriend" />
			<input type="hidden" value="${direct}" name="direct" />
			<c:if test="${!friend}">
				<input type="submit" value="Add" />	
			</c:if>
		</form>
		
		<form method="GET" action="./message?username=${userMap['username']}">
				<input type="hidden" value="${userMap['username']}" name="username"/>
				<input type="submit" value="Send Message" />		
		</form>
		<form method="GET" action="./helpRequest?username=${userMap['username']}">
				<input type="hidden" value="${userMap['username']}" name="username"/>
				<c:if test="${sessionScope.user_type == 'logged' || sessionScope.user_type == 'admin'}">
					<input type="submit" value="Ask Help" />
				</c:if>		
		</form>
		
		<br /><br />
		
		<h3>User Abilities</h3>
		<ul>
			<c:forEach var="ability" items="${abilitiesMap}">
		    	<li>
		    		<details>
						<summary>Name: ${ability.key}</summary>
						<p>${ability.value}</p>
					</details>
				</li>
		    </c:forEach>
	    </ul>
	
    </jsp:body>
</t:basicTemplate>